<%@ page import="model.User" %>
<%@ page import="java.util.List" %>
<%@ page import="model.Essay" %><%--
  Created by IntelliJ IDEA.
  User: 12138
  Date: 2020/12/22
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>网站管理界面</title>
    <link rel="stylesheet" type="text/css" href="css/style_management.css">
    <link rel="stylesheet" type="text/css" href="css/common_management.css">
</head>
<%
    List<Essay> essayList=(List<Essay>) session.getAttribute("essayList");
    List<User> userList=(List<User>) session.getAttribute("userList");
%>
<body>

<div id="head">
    <h1>管理员后台</h1>
    <ul id="headButton">
        <li class="icon-sk011">用户：admin</li>
        <li id="li_out" class="icon-sk012">退出后台</li>
    </ul>
</div>
<div id="left">
    <ul class="nav">
        <li class="current">
            <h4 class="title"><i class="icon-sk005"></i><a href="javascript:;">文章维护</a></h4>
            <ul hidden="true">
                <li><a id="a_essay_manage">管理文章</a></li>
            </ul>
        </li>
        <li class="current">
            <h4 class="title"><i class="icon-sk011"></i><a href="javascript:;">用户数据</a></h4>
            <ul hidden="true">
                <li><a id="a_user_manage">管理用户</a></li>
            </ul>
        </li >
        <li class="current">
            <h4 class="title"><i class="icon-sk057"></i><a href="javascript:;">其他</a></h4>
            <ul hidden="true">
                <li><a id="a_about_us">关于我们</a></li>
            </ul>
        </li>
    </ul>
</div>
    <div id="main">
    <div class="main_content" id="welcome"><h1>欢迎进入仓颉微博管理后台</h1>
    </div>
    <div class="main_content" id="essay_manage" >

        <div id="table_data" >
            <div class="table" style="width:95%; height:500px;overflow-y: auto;margin: 0 auto;text-align:center">
                <table id="DataTable"  width="100%" cellspacing="0" cellpadding="0" style="text-align: center" >
                    <thead class="table_head" >
                    <tr>
                        <th width="10%" style="text-align: center">文章ID</th>
                        <th width="25%" style="text-align: center">文章标题</th>
                        <th width="20%" style="text-align: center">创建时间</th>
                        <th width="20%" style="text-align: center">修改时间</th>
                        <th width="5%" style="text-align: center">分类</th>
                        <th width="10%" style="text-align: center">作者</th>
                        <th width="10%" style="text-align: center">操作</th>
                    </tr>
                    </thead>
                    <tbody id="DataTableInput">
                    <tr class="item" >
                        <td> 1</td>
                        <td>你不一定全知道的四种Python装饰器实现详解</td>
                        <td>2020-12-12|00:00:00</td>
                        <td>2020-12-12|00:00:00</td>
                        <td>技术</td>
                        <td>1</td>
                        <td><a name="EssayDelete" class="btn pill fill">删除</a></td>
                    </tr>

                    </tbody>
                </table>

            </div>
        </div>

    </div>
        <div class="main_content" id="user_update" >
            <br>
            <br>
            <br>
            <form method="post" action="/QM_war_exploded/UserUpdate" id="UserUpdateForm" style="margin-left: 50px">
                 <input type="hidden" id="formUid" value="" name="fromUid" readonly="readonly"  >
                <table >
                    <tbody>
                    <tr><td>用户名</td><td><input id="formUsername" type="text" name="username" value="" readonly="readonly" ></td></tr>
                    <tr><td>密码</td><td> <input id="formPassword" type="text" name="password" value="" ></td></tr>
                    <tr><td><input type="submit" value="更新密码" align="center"></td></tr>
                    </tbody>
                </table>


            </form>
        </div>
        <div class="main_content" id="user_manage" >
            <div id="user_data" >
            <div class="table" style="width:95%; height:500px;overflow-y: auto;margin: 0 auto;text-align:center">
                <table id="UserTable"  width="100%" cellspacing="0" cellpadding="0" style="text-align: center" >
                    <thead class="table_head" >
                    <tr>
                        <th width="5%" style="text-align: center">用户ID</th>
                        <th width="22%" style="text-align: center">用户名</th>
                        <th width="22%" style="text-align: center">密码</th>
                        <th width="20%" style="text-align: center">创建时间</th>
                        <th width="20%" style="text-align: center">修改时间</th>
                        <th width="10%" style="text-align: center">操作</th>
                    </tr>
                    </thead>
                    <tbody id="UserTableInput">
                    <tr class="item" >
                        <td> 1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>2020-12-12|00:00:00</td>
                        <td>2020-12-12|00:00:00</td>
                        <td><a name="UserUpdate" class="btn pill fill" style="margin-top: 5px">修改</a> <a name="UserDelete" class="btn pill fill">删除</a></td>
                    </tr>

                    </tbody>
                </table>

            </div>
            </div>
        </div>

    <div class="main_content" id="about_us" >

        <p class="about"> <img src="img/about.gif"><br> 联系方式↓<br>
            客服热线：0577-88352156<br>
            qq邮箱：387617119@qq.com</p>
    </div>
</div>
<div id="bottom">
    <p >Copyright©2020 仓颉博客版权所有</p>
</div>

</body>

<script src="${pageContext.request.contextPath }/js/echarts.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/js/jquery-3.5.1.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/editor_api.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/zh-cn.js"></script>
<script type="text/javascript">
    $(document).ready(function(){



        main_init();
        //数据变动提醒按钮效果实现
        var flag=false;
        $("#li_out").on("click",function () {
            window.location.href = "index.jsp";
        })


        //侧边菜单效果实现
        $(".nav .title").on("click",function(){
            if($(this).siblings("ul").css("display")=="block"){
                //if($(this).siblings("ul").is(:v)){
                $(this).siblings("ul").hide(500);//hide隐藏
                //$(this).children("i")//直属子标签
                $(this).find("i").removeClass("fa fa-minus-square").addClass("fa fa-plus-square");//find所有字标签
            }else{
                $(this).siblings("ul").show(500);//siblings查找同辈
                $(this).find("i").removeClass("fa fa-plus-square").addClass("fa fa-minus-square");
                $(this).parent().siblings().children("ul").hide();
                $(this).parent().siblings().children("i").removeClass("fa fa-minus-square").addClass("fa fa-plus-square");
            }
        });

        function main_init(){
            $("#welcome").show();
            $("#welcome").siblings().hide();
            $("#DataTableInput").empty();
            $("#UserTableInput").empty();
            <%for (User u :userList ) {
            if(u.getRole_id()==1){}else {%>
                var str='  <tr class="item" >\n' +
                    '                        <td><%=u.getUid()%></td>\n' +
                    '                        <td><%=u.getUsername()%></td>\n' +
                    '                        <td><%=u.getPassword()%></td>\n' +
                    '                        <td><%=u.getCreatetime()%></td>\n' +
                    '                        <td><%=u.getModifytime()%></td>\n' +
                    '                        <td><a  name="UserUpdate" class="btn pill fill update" style="margin-top: 5px">修改<input type="hidden" value="<%=u.getUid()%>" name="fromUid"><input type="hidden" value="<%=u.getUsername()%>" name="fromUsername"><input type="hidden" value="<%=u.getPassword()%>" name="fromPassword"></a> <a  name="UserDelete" class="btn pill fill del">删除'+
                    '<form hidden="true" method="post" action="/QM_war_exploded/UserDel" style="z-index: 999">\n' +
                    '   <input type="hidden" value="<%=u.getUid()%>" name="fromUid"> ' +
                    '    <input type="submit"  value="提交">\n' +
                    '</form></a>'+
                    '</td>\n' +
                    '                    </tr>'
                    $("#UserTableInput").append(str)
            <%}}%>
            <%for (Essay e :essayList ) {%>
                var str1='  <tr class="item" >\n' +
                    '                        <td><%=e.getEid()%></td>\n' +
                    '                        <td><%=e.getTitle()%></td>\n' +
                    '                        <td><%=e.getCreate_time()%></td>\n' +
                    '                        <td><%=e.getUpdate_time()%></td>\n' +
                    '                        <td><%=e.getEclass()%></td>\n' +
                    '                        <td><%=e.getAuther()%></td>\n' +
                    '                        <td><a name="EssayDelete" class="btn pill fill Delete">删除'+
                    '<form hidden="true" method="post" action="/QM_war_exploded/EssayDelAdmin" style="z-index: 999">\n' +
                    '   <input type="hidden" value="<%=e.getEid()%>" name="fromeid"> ' +
                    '    <input type="submit"  value="提交"></form>\n' +
                    '</a></td>\n' +
                    '                    </tr>'
                $("#DataTableInput").append(str1)
            <%}%>
        }
        $(".Delete").on("click",function () {
            alert("Del")
            alert($(this).children("form").children("input[name='fromeid']").val())
            $(this).children("form").submit();
        })
        $(".update").on("click",function (){
            alert("修改")
            var uid=$(this).children("input[name='fromUid']").val();
            var uesrname=$(this).children("input[name='fromUsername']").val();
            var password=$(this).children("input[name='fromPassword']").val();
            alert("up"+uid)

            $("#formUid").val(uid);
                <%for (User u :userList ){%>
            $("#formUsername").val(uesrname);
            $("#formPassword").val(password);
            <%}%>

            $("#user_update").show();
            $("#user_update").siblings().hide();
        })
        $(".del").on("click",function (){
           alert("删除")
            var uid=$(this).children('form').children("input[name='fromUid']").val();
            alert(uid)
            var uid=$(this).children('form').submit();

        })
        $("#a_essay_manage").on("click",function(){
           // alert("essay_manage");
            $("#essay_manage").show();
            $("#essay_manage").siblings().hide();
        });

        $("#a_user_manage").on("click",function(){
            //alert("zan_sum");
            $("#user_manage").show();
            $("#user_manage").siblings().hide();
        })	;

        $("#a_about_us").on("click",function(){
           // alert("about_us");
            $("#about_us").show();
            $("#about_us").siblings().hide();
        });
    });
</script>




</html>